package com.hualan.zhsq.controller.property;

import com.hualan.zhsq.entity.property.Activity;
import com.hualan.zhsq.service.property.ActivityService;
import com.hualan.zhsq.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ActivityController
 * @Description 活动管理controller
 * @Author ZheRan
 * @Date 2025年08月04日 下午8:52
 * @Version 1.0
 */
@RestController
public class ActivityController {
    @Autowired
    private ActivityService activityService;

    //插入一条数据
    @PostMapping("/activity/add")
    public Result add(@RequestBody Activity activity) {
        return Result.success(activityService.add(activity));
    }

    //修改一条数据
    @PutMapping("/activity/edit")
    public Result edit(@RequestBody Activity activity) {
        return Result.success(activityService.edit(activity));
    }

    //根据id逻辑删除数据
    @DeleteMapping("/activity/remove/{id}")
    public Result remove(@PathVariable Integer id) {
        return Result.success(activityService.remove(id));
    }

    //批量逻辑删除数据
    @DeleteMapping("/activity/removeBatch")
    public Result removeBatch(@RequestBody Integer[] ids) {
        return Result.success(activityService.removeBatch(ids));
    }

    //根据id查询数据
    @GetMapping("/activity/findById/{id}")
    public Result findById(@PathVariable Integer id) {
        return Result.success(activityService.findById(id));
    }

    //查询所有数据
    @GetMapping("/activity/findPage")
    public Result findPage() {
        return Result.success(activityService.findPage(1, 10, new Activity()));
    }
}
